<!DOCTYPE html>
<html lang="en" xmlns:v-model="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>天帝吧</title>
    <script src="js/vue/vue.min.js"></script>
    <script src="js/js-cookie/js.cookie.min.js"></script>
    <script src="js/jquery/jquery.min.js"></script>
    <script src="js/jquery/jquery.form.js"></script>
    <script src="js/vue/common.js"></script>
    <script src="js/vue/moment.min.js"></script>


</head>
<body>
<div>
    天帝吧<br>
    <a href="login.html">登录</a>
</div>
<div id="app">
    <li v-for="item in notelist">
        {{item.id}}------------{{item.notedetialTitle}}---------------{{item.createtime|dateFormat}}
    </li>
    <br>
    <form id="noteFormId">
        发表回复<input type="text" name="notedetialTitle" id="id"><br>
        <input type="button" value="发布" @click="submitForm()">
    </form>
    <a href="rank.html">排行榜</a>
</div>

</body>
<script>

    var vue = new Vue({
        el: "#app",
        data: {
            notelist: []
        },
        methods: {
            submitForm: function () {
                // 获取页面传进来的参数
                var notedetialTitle =$('#id').val()
                ajaxPost("/notelist/save",{notedetialTitle:notedetialTitle}, function (data) {
                    vue.abroadCds = data.data;
                    if (data.code ==200){
                        window.location.reload();
                    }
                })
            }
        },
        mounted: function () {
            var _this = this;
            $.get("http://localhost:8080/notelist/list", {}, function (data) {
                _this.notelist = data.data;
            });
        },
        filters: {
            dateFormat: function (date) {
                return dateFormat(date, "YYYY-MM-DD HH:mm:ss")
            }
        },
    });

    //格式转换
    function dateFormat(date, pattern){
        if(!pattern){
            pattern = "YYYY-MM-DD"
        }
        return moment(date).format(pattern)
    }
</script>
</html>